﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Microsoft.Office.Server;
using Microsoft.Office.Server.SocialData;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;

namespace Schwazzle.Test.Services
{
    public class TagsServiceTests
    {
        [Test]
        public void GetTagsByNameTest()
        {
            string sitename = "http://vaiopony";
            Schwazzle.Core.Services.TagsService service = new Core.Services.TagsService(sitename);
            SocialUrl[] urls = service.GetTagsByName("4Me", @"VAIOPONY\kev.000");

            Assert.IsTrue(urls.Count() > 0);
        }

        [Test]
        public void GetListItemChangesTest()
        {
            string sitename = "http://vaiopony";
            Schwazzle.Core.Services.TagsService service = new Core.Services.TagsService(sitename);
            List<SPListItem> items = service.GetListItemChanges("4Me", @"VAIOPONY\kev.000");

            Assert.IsTrue(items.Count() > 0);
        }

        [Test]
        public void GetColleaguesTagsTest()
        {
            string sitename = "http://vaiopony";
            Schwazzle.Core.Services.TagsService service = new Core.Services.TagsService(sitename);
            List<SPListItem> items = service.GetColleaguesTags("4Me", @"VAIOPONY\kevmcdonk");
            Assert.IsTrue(items.Count() > 0);
        }

        //[Test]
        public void GetChangesUsingCrossSiteQuery()
        {
            /*
            string sitename = "http://vaiopony";
            using (SPSite site = new SPSite(sitename))
            {
                SPSiteDataQuery query = new SPSiteDataQuery();

                //Ask for all lists created from the contacts template.
                string listQuery = "<Lists>";
                listQuery += "<List ID=\"7A9FDBE6-0841-430a-8D9A-53355801B5D5\" />";
                listQuery += "<List ID=\"3D18F506-FCA1-451e-B645-2D720DC84FD8\" />";
                listQuery += "</Lists>";
                query.Lists = listQuery;

                // Get the Title (Last Name) and FirstName fields.
                query.ViewFields = "<FieldRef Name=\"Title\" />" +
                                   "<FieldRef Name=\"FirstName\" Nullable=\"TRUE\" Type=\"Text\"/>";
                // Note that setting the Nullable attribute to TRUE
                // causes an empty value to be returned for lists that
                // do not include the FirstName column. The default is 
                // to skip a list that does not include the column.

                // Set the sort order.
                query.Query = "<OrderBy>" +
                                  "<FieldRef Name=\"Title\" />" +
                              "</OrderBy>";

                // Query all Web sites in this site collection.
                query.Webs = "<Webs Scope=\"SiteCollection\" />";

                DataTable dt = web.GetSiteData(query);
            }
             * */
        }

        public void GetLatestChanges()
        {
            string sitename = "http://vaiopony";
            Schwazzle.Core.Services.TagsService service = new Core.Services.TagsService(sitename);
            SocialUrl[] urls = service.GetTagsByName("4Me", @"VAIOPONY\kev.000");
            
        }
    }
}
